<?php
    include_once("../action/checkAuthenticationAction.php");
    include_once("../service/bannerService.php");
	include_once("../util/constant.php");
    include_once("../util/message.php");
    
    include_once("../util/authUtil.php");
    $perm_array = $_SESSION["permissions"];
?>
<!DOCTYPE html>
<head>
	<title>Dashboard</title>
	<?php include("import-css.php");?>	
    <style>
        
    </style>
</head>
<body>
	<?php include("header.php");?>
    
    <div class="container-fluid">
		<div class="row-fluid">
            <!--Menu-->
            <?php include("menu.php");?>
            <!--Content-->
            <div class="box span10 offset2">
                <div class="box-content">
                <?php
                    if(!authUtil(array("edit banner","create branch"),$perm_array,false)){
                        echo "<script>window.location.href='../admin/index.php';</script>";
                    }
                ?>
					<form class="form-horizontal" method="POST" id="banner_enabler_form" action="../action/banner_enabler_action.php">
						<div class="control-group">
                            <?php
                                $leftBanner = getActiveLeftBanner();
                                $centerBanner = getActiveCenterBanner();
                                $rightBanner = getActiveRightBanner();
                                $eventBanner = getActiveEventBanner();
                            ?>
                            <label class="control-label" for="order">Banner trái</label>                            
                            <div class="controls">
                                 <select id="left" name="left">
                                    <option value="0">Không chọn</option>
                                    <?php
                                        $banner1 = getAllLeftBanner();
                                        while($banner = mysql_fetch_array($banner1)){
                                    ?>
                                        <option <?php echo isset($leftBanner)&&$leftBanner["BANNER_ID"]==$banner["BANNER_ID"]?"selected":""; ?> value="<?php echo $banner["BANNER_ID"]; ?>"><?php echo $banner["EVENT_TITLE"]; ?></option>
                                    <?php
                                        }
                                    ?>
                                 </select>
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label" for="order">Banner giữa</label>
                            <div class="controls">
                                 <select id="center" name="center">
                                    <option value="0">Không chọn</option>
                                    <?php
                                        $banner2 = getAllCenterBanner();
                                        while($banner = mysql_fetch_array($banner2)){
                                    ?>
                                        <option <?php echo isset($centerBanner)&&$centerBanner["BANNER_ID"]==$banner["BANNER_ID"]?"selected":""; ?> value="<?php echo $banner["BANNER_ID"]; ?>"><?php echo $banner["EVENT_TITLE"]; ?></option>
                                    <?php
                                        }
                                    ?>
                                 </select>
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label" for="order">Banner phải</label>
                            <div class="controls">
                                 <select id="right" name="right">
                                    <option value="0">Không chọn</option>
                                    <?php
                                        $banner3 = getAllRightBanner();
                                        while($banner = mysql_fetch_array($banner3)){
                                    ?>
                                        <option <?php echo isset($rightBanner)&&$rightBanner["BANNER_ID"]==$banner["BANNER_ID"]?"selected":""; ?> value="<?php echo $banner["BANNER_ID"]; ?>"><?php echo $banner["EVENT_TITLE"]; ?></option>
                                    <?php
                                        }
                                    ?>
                                 </select>
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label" for="order">Banner sự kiện</label>
                            <div class="controls">
                                 <select id="event" name="event">
                                    <option value="0">Không chọn</option>
                                    <?php
                                        $banner4 = getAllEventBanner();
                                        while($banner = mysql_fetch_array($banner4)){
                                    ?>
                                        <option <?php echo isset($eventBanner)&&$eventBanner["BANNER_ID"]==$banner["BANNER_ID"]?"selected":""; ?> value="<?php echo $banner["BANNER_ID"]; ?>"><?php echo $banner["EVENT_TITLE"]; ?></option>
                                    <?php
                                        }
                                    ?>
                                 </select>
                            </div>
                        </div>
                        <center>
                            <button type="submit" class="btn btn-primary">
    							Cập nhật
    						</button>
                        </center>
					</form>
				</div>                
            </div><!--/span-->
        </div>
    </div>

    <?php include("footer.php");?>
		
	</div><!--/.fluid-container-->

	<?php include("import-js.php");?>	
</body>
</html>
